QT += quick widgets

CONFIG += c++14

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    src/main.cpp \
    src/FileIO.cpp \
    src/Process.cpp

HEADERS += \
    src/FileIO.h \
    src/Process.h

RESOURCES += \
    qml/qml.qrc \
    images/images.qrc

OTHER_FILES += \
    scripts/* \
    images/icons/* \
    images/appicon/* \
    images/bg/* \
    README.md

BASEVERSION = $$system(cat $$PWD/VERSION)
COMMIT = $$system(git -C $$PWD rev-parse --short HEAD)
VERSION = "$$BASEVERSION ($$COMMIT)"
DEFINES += VERSION=\\\"\"$$VERSION\"\\\"

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DESTDIR = $$OUT_PWD/root/usr/bin

copy_scripts.commands = $(COPY_DIR) $$PWD/scripts $$OUT_PWD/root/usr
first.depends = $(first) copy_scripts
export(first.depends)
QMAKE_EXTRA_TARGETS += first copy_scripts

APPIMAGE=$$(APPIMAGE)
!isEmpty(APPIMAGE) {
    message("AppImage")

    copy_share.commands = $(COPY_DIR) $$PWD/share $$OUT_PWD/root/usr
    first.depends += copy_share
    export(copy_share.commands)
    QMAKE_EXTRA_TARGETS += copy_share

    copy_qml.commands = \
        $(MKDIR) $$OUT_PWD/root/usr/qml; \
        $(MKDIR) $$OUT_PWD/root/usr/lib; \
        $(COPY_DIR) \
            $$(QTDIR)/qml/Qt \
            $$(QTDIR)/qml/QtQml \
            $$(QTDIR)/qml/QtQuick \
            $$(QTDIR)/qml/QtQuick.2 \
            $$(QTDIR)/qml/QtGraphicalEffects \
            $$OUT_PWD/root/usr/qml; \
        $(COPY_FILE) \
            $$(QTDIR)/lib/libQt5QmlWorkerScript.so.5 \
            $$(QTDIR)/lib/libQt5QmlModels.so.5 \
            $$(QTDIR)/lib/libQt5Quick.so.5 \
            $$(QTDIR)/lib/libQt5QuickTemplates2.so.5 \
            $$(QTDIR)/lib/libQt5QuickControls2.so.5 \
            $$OUT_PWD/root/usr/lib
    first.depends += copy_qml
    export(copy_qml.commands)
    QMAKE_EXTRA_TARGETS += copy_qml

    QMAKE_POST_LINK = VERSION=$$BASEVERSION-$$COMMIT linuxdeploy-x86_64.AppImage --appdir $$OUT_PWD/root --plugin qt --output appimage
}
